package baseTest;

public class findDuplicate {
    public static void main(String[] args) {
        int[] nums = {1,3,4,2,2};
        System.out.println(process(nums));

    }

    public static int process(int[] nums){
        int n = 0;
        int m = 0;
        while (nums[n] == n+1){
            n++;
        }
        while (nums[n] != m){
            m = nums[n];
            nums[n] = nums[m];
            nums[m] = m;
        }
        return m;
    }
}
